<template>
  <div class="hello">
    <div class="header">
      <p class="comName">
        <span>成都希古尚博实业有限公司</span>
        <span style="margin-top: 35px ;font-size:24px">SHIGOO SYMBOLE INVESTMENTS</span>
      </p>
    </div>
    <div class="login" style="margin-top: 60px;"><i class="i1"></i><input type="text" name="" placeholder="请输入用户名" v-model="username" @keyup.13="login"></div>
    <div class="login" style="margin-top: 30px"><i class="i2"></i><input type="password" name="" placeholder="请输入密码" v-model="password" @keyup.13="login"></div>
    <div class="concern"><span v-show='logininfo'>帐号或密码不能为空</span></div>
    <div class="concern" style="text-align: left;"> <el-checkbox v-model="checked">记住帐号</el-checkbox></div>
    <button class="logBtn" v-on:click="login">登&nbsp&nbsp&nbsp&nbsp录</button>




 <el-dialog title="提示" :visible.sync="dialogVisible1" size="tiny" :show-close="false">
  <span>登录失败,请检查您的账号和密码</span>
  <span slot="footer" class="dialog-footer">
    <el-button type="primary" @click="dialogVisible1 = false">重新登录</el-button>
  </span>
</el-dialog> 
  
    
   
</div>
</template>

<script>
export default {
    data() {
      return {
        logininfo:false,
        checked: true,
        username:"",
        password:"",
        dialogVisible: false,
         dialogVisible1: false,
         dialogVisible2: false,
      };
    },
    methods:{
       
      login:function  () {
        // body... 
        if (this.username&&this.password) {
        var _this = this
        this.$http.post('http://api.kx910.com/api/admin/login',{
          username:this.username,
          password:this.password
        })
        .then(function(res){
          console.log(res)
          if (res.data.code==0) {
             _this.dialogVisible1 = true
             
           }else {
             _this.dialogVisible2 = true
             sessionStorage.token=res.data.data.token
             sessionStorage.username = res.data.data.username
             _this.$router.push('/index')
           }
         
        })
      }else {
        this.logininfo = true
      }
      }

    }
  };</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

  .header{
    width: 100%;
    height: 300px;
    background: url(../../assets/img/login-banner.png);
  }
  .comName{
    text-align: center;
    vertical-align: middle;
    font-size: 36px;
    color: white;
    padding-top: 125px;
  }
  .comName span{
    display: block;

  }
  .comName span:last-child{
    margin-left: 234px;
  }
  .login input{
    width: 400px;
    height: 60px;
    border-radius: 30px;
    border: 2px solid;
    border-color: rgb(119,119,119);
    outline: none;
    padding: 20px 70px;
    font-size: 18px;
    margin:0 auto;
    position: relative;
  }
  .login{
    width: 404px;
    text-align: center;
    margin: 0 auto;
    position: relative;
  }
.login i {
  display: block;
  position: absolute;left: 0;
 
  width: 30px;height: 30px;
  z-index: 20;
  left: 30px;top: 15px
}
.i1{
  background: url(../../assets/img/用户.png);
}
.i2{
  background: url(../../assets/img/密码.png) no-repeat;
}
.concern{
  color: #ff0000;
  font-size: 10px;
  width: 404px;
   margin: 0 auto;
   text-align: right;
   padding: 10px 0px
}
.logBtn{
   width: 400px;
    height: 60px;
    border-radius: 30px;
    border: none;
    border-color: rgb(119,119,119);
    outline: none;
    margin:0 auto;
    position: relative;
    display: block;
    font-size: 30px;
    background-color: #0068b7;color: white;
     margin-top: 30px;
}
</style>
